import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WinVO, WinForm, WinQuery } from '@/api/business/win/types';

/**
 * 查询飘窗分类列表
 * @param query
 * @returns {*}
 */

export const listWin = (query?: WinQuery): AxiosPromise<WinVO[]> => {
  return request({
    url: '/business/win/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询飘窗分类详细
 * @param baseId
 */
export const getWin = (baseId: string | number): AxiosPromise<WinVO> => {
  return request({
    url: '/business/win/' + baseId,
    method: 'get'
  });
};

/**
 * 新增飘窗分类
 * @param data
 */
export const addWin = (data: WinForm) => {
  return request({
    url: '/business/win',
    method: 'post',
    data: data
  });
};

/**
 * 修改飘窗分类
 * @param data
 */
export const updateWin = (data: WinForm) => {
  return request({
    url: '/business/win',
    method: 'put',
    data: data
  });
};

/**
 * 删除飘窗分类
 * @param baseId
 */
export const delWin = (baseId: string | number | Array<string | number>) => {
  return request({
    url: '/business/win/' + baseId,
    method: 'delete'
  });
};
/**
 * 是否展示
 */
export const visibleChange = (baseIds: Array<string | number>, status: boolean) => {
  return request({
    url: '/business/win/visible',
    method: 'post',
    data: {
      baseIds: baseIds,
      status: status
    }
  });
};
